package com.sophialex.health.record.common.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sophialex.health.common.platform.exception.BusinessException;
import com.sophialex.health.system.frame.util.Assert;

/**
 * 参数工具类
 * 
 * @author L.P
 * 
 */
public class ParamUtil {

	public final static String FSHOWZERO = "fshowck";// 出库显示零库存
	public final static String RKMRFS = "rkmrfs";// 入库默认方式为比例 入库
	public final static String JHDJPOS = "JHDJPOS";// 进价单价显示位数
	public final static String PFDJPOS = "PFDJPOS";// 批发单价显示位数
	public final static String LSDJPOS = "LSDJPOS";// 零售单价显示位数
	public final static String DEFAULTBL = "DEFAULTBL";// 默认进销比率
	public final static String MAXYXBL = "MAXYXBL";// 最大进销比率
	public final static String ZBBL_KEY = "ZBBL";// 招标比率
	public final static String FDL = "FDL";// 浮动率
	public final static String RKXGYXBL = "6";// 入库时能否修改进销比例
	public final static String JEXSPOS = "20";// 金额 显示位数
	public final static String ZBGSQY = "19"; // 招标公式启动
	public final static String PdGJDJ = "8";// 判断国家定价
	public final static String ZBLSJ_MODE = "ZBLSJ_MODE";

	public final static String LOWER_CLARM = "1"; // 下限报警
	public final static String UPPER_CLARM = "2"; // 上限报警
	public final static String LOWERUPPER_CLARM = "3"; // 上下限报警
	public final static String SAFE_CLARM = "4"; // 安全库存报警
	public final static String SK_QY_KEY = "SKYPXJ";// 是否启用社康零加成

	// 招标零售价高于政府定价时:
	// 0：以政府定价入库；
	// 1：仍以零售价入库；
	// 2：禁止入库；
	public final static String RkXTPH = "RkXTPH ";// 同一张入库单允许录入相同批次药品
	public final static String QYSH_KEY = "qysh";// 启用审核
	public final static String AutoPH_KEY = "AutoPH";// 入库单批号取上次入库批号
	/************** 进销比率 **********************/
	public final static String QS_XY_ZK_BL = "11";// 西药有折扣
	public final static String QS_ZCY_ZK_BL = "12";// 中草药有折扣
	public final static String QS_ZCHY_ZK_BL = "13";// 中成药有折扣
	public final static String QS_QT_ZK_BL = "14";// 其他药有折扣

	public final static String QS_XY_BL = "15";// 西药无折扣
	public final static String QS_ZCY_BL = "16";// 中草药无折扣
	public final static String QS_ZCHY_BL = "17";// 中成药无折扣
	public final static String QS_QT_BL = "18";// 其他药无折扣
	public final static String QY_LED = "60";//启用LED显示屏

	public static Double YXBL = 1.15D; // 进销比率
	public static Double ZBBL = 1.15D;// 招标比率

	public static boolean AutoPh = false;// 入库单批号取上次入库批号
	public static String QYSH = "1"; // 启用审核
//	public static Tzdmx ZBGS_ZD = null;
	public static String SK_QY = "0";// 启用社康零加成
	

	// 门诊发药从参数
	public final static String ISLINKMZDOC = "71";
	public final static String ISLINKSFINFO = "sfInfo"; // 连接收费信息
	public final static String ISLINKMZPY = "51"; // 启用门诊配药
	public final static String ISQYSJ = "fyxssj"; // 住院发药是否显示时间（显示全部申请）
	public final static String YBTWOCOPIES = "YBTWOCOPIES";// 医保病人打印两份药品发药清单
	public final static String MZPYISPRINT = "MzpyIsPrint";// 门诊配药是否打印清单
	public final static String MZFYOPEN = "mzfyopen";// 门诊发药窗口强制打开
	public final static String MZFYDYYL = "MZFYYL";// 门诊发药预览
	public final static String MZPYDYYL = "prview";// 门诊配药预览
	public final static String MZFYKC = "mzfykc";// 门诊发药扣库存方式 1划价扣除库存、2发药扣除库存
	public final static String ALLMZPYFDY = "allpyddy";// 全部药品打印配药单

	// 住院发药参数
	public final static String FFYTYSTATE = "ffyty";// 控制发药退药是否可以一起控制
	public final static String ZYSQMODE = "zysqmode"; // 住院发药查询是按科室还是申请科室查询:0科室,1申请科室
	public static final String ISQYHLYY = "isqyhlyy"; // 是否启用合理用药
	public final static String ZyFYISPRINT = "ZyfyIsPrint";// 住院发药是否打印清单
	public final static String ZyPRINTPROMPT = "ZyPrintPrompt";// 住院发药打印提示窗口,1为打开,0为不打开
	public static Double Xddj = 500D;// 进货价超过该价钱，零售价只能按进货价+限定加成金额
	public static Double Xdjc = 75D;// 限定加成
	// public static String ISZYFYDY = "iszyfydy";//住院发药清单是否打印

	public final static String ZYFYDYYL = "ZYFYYL";// 住院发药预览
	public final static String ZYFYBRINFO = "ZYFYBRINFO";//按病人发药是否打印病人详细信息,1为打开，默认为0不打开
	public final static String OVERDUE = "5"; // 药品过期
	public final static String BJ_ALL = "0";
	public static String clarmType = BJ_ALL; // 自动报警类型
	public final static String DYHFY = "77";// 住院发药先打印后发药
	public final static String DYSORT = "dysort";// 单据打印排序
	public final static String RKFS_KEY = "rkfs";// 默认入库方式
	public final static String JGLD_KEY = "jgld";// 价格联动(调价时修改门诊单位会按比例修改住院单位)

	public final static String MZCFDY = "dzcfdy";// 是否打印处方,默认1

	public final static String AUTO_YPBH = "zdscypbh";// 自动生成药品编号
	public final static String QY_LCJ = "qylcj";// 启用零差价
	public final static String QY_CJYP = "isypcjrk";// 差价入库药品
	public static String RKFS = "4"; // 默认实价入库
	public static boolean JGLD = false;// 默认不修改

	public static String ZWMM = "90";// 帐务管理员密码
	
	public static String ISYPTYTJ = "isyptytj";// 药品统一调价
	
	public static String WLSQKC = "wlsqkc";// 药品统一调价

	public static Map<String, String> map = new HashMap<String, String>();

	/**
	 * 生成采购计划单表格列显示时的宽度
	 */
	public static final int[] purchaseColWeidth = new int[] { 60, 160, 120, 60,
			60, 60, 100, 100, 60, 80, 80, 80, 120, 80, 80, 80, 100, 120, 60,
			60, 60, 60, 60, 60, 60, 60,60,60,60,60,60,60,60,60,60,60,60 };

	static {
		initParam();
		MzFyContants.initFySetting();
		
	}

	public static void initParam() {
		RKFS = "4";
		JGLD = false;
		YXBL = 1.15D;
		ZBBL = 1.15D;
		QYSH = "1";
		AutoPh = false;
		SK_QY = "0";
		try {
//			List<Tparam> list = YfLocalCache.getTparam();
//			if (list != null && list.size() > 0) {
//				for (Tparam param : list) {
//					map.put(param.getId().getFcode(), param.getFvalue());
//				}
//			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		String str = map.get(DEFAULTBL);
		if (!Assert.isNull(str)) {
			YXBL = Double.valueOf(str);
		}
		str = map.get(ZBBL_KEY);
		if (!Assert.isNull(str)) {
			ZBBL = Double.valueOf(str);
		}
		str = map.get(QYSH_KEY);
		if (!Assert.isNull(str)) {
			QYSH = str;
		}
		str = map.get(AutoPH_KEY);
		AutoPh = "1".equals(str);
		str = map.get(SK_QY_KEY);
		if (!Assert.isNull(str)) {
			SK_QY = str;
		}
		str = map.get(RKFS_KEY);
		if (!Assert.isNull(str)) {
			RKFS = str;
		}
		str = map.get(JGLD_KEY);
		if (!Assert.isNull(str)) {
			JGLD = "1".equals(str) ? true : false;
		}

	}

	public static void refresh() {
//		YfLocalCache.paramList = null;
		map.clear();
		initParam();
	}

	public static String getParamValue(String code) {
		return map.get(code);
	}

	/**
	 * 获取招标公式
	 * 
	 * @return
	 */
	public static String getZbGs() {
//		if (ZBGS_ZD == null) {
//			try {
//				List<Tzdmx> list = DataSource.comService.getTzdmx("tparam",
//						ZBGSQY, null);
//				if (list != null && list.size() > 0) {
//					ZBGS_ZD = list.get(0);
//				}
//			} catch (BusinessException e) {
//				e.printStackTrace();
//			}
//		}
//		return ZBGS_ZD == null ? "" : ZBGS_ZD.getFmc();
		return null;
	}
}
